import request from '@/utils/request'

// 获取轮播图分页列表
export function getBannerPage(params) {
  return request({
    url: '/banner/page',
    method: 'get',
    params
  })
}

// 添加轮播图
export function addBanner(data) {
  return request({
    url: '/banner/add',
    method: 'post',
    data
  })
}

// 更新轮播图
export function updateBanner(data) {
  return request({
    url: '/banner/update',
    method: 'post',
    data
  })
}

// 删除轮播图
export function deleteBanner(bannerId) {
  return request({
    url: `/banner/delete/${bannerId}`,
    method: 'post'
  })
}

// 修改轮播图状态
export function changeBannerStatus(bannerId, isVisible) {
  return request({
    url: `/banner/status/${bannerId}`,
    method: 'post',
    params: { isVisible }
  })
}

// 上传图片
export function uploadImage(file) {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: '/api/upload',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}